//
//  LoginViewController.m
//  ShowYork
//
//  Created by hxh on 2020/8/24.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "LoginViewController.h"
#import "DiscoverListViewController.h"
#import "LoginAndRegisterTitleView.h"
#import "OtherLoginView.h"
#import "MKAppleLogin.h"
#import "LoginParamModel.h"
#import "UserInfoFollowModel.h"
#import "OtherLoginUserInfoModel.h"
@interface LoginViewController ()<TTTAttributedLabelDelegate,MKAppleLoginDelegate>
/*控件*/
/// 标题
@property (nonatomic,strong)LoginAndRegisterTitleView *titleView;
/// 第三方登录视图
@property (nonatomic,strong)OtherLoginView *otherView;

@property (nonatomic,strong)UIView *phoneView;
/// 输入框
@property (nonatomic,strong)UITextField *phoneTF;
/// 按钮
@property (nonatomic,strong)UIButton *codeBtn;
/*参数对象*/
@property (nonatomic,strong)LoginParamModel *loginParamModel;

@property (nonatomic, strong) CAGradientLayer *loginBtnGradientLayer;


@property (nonatomic,strong)UIImageView *loginBackGroundImgView;

@property (nonatomic,strong)UIButton *backButton;

@property (nonatomic,strong)UIButton *clearTextButton;

@property (nonatomic,strong)UILabel *placeLb;

@property (nonatomic,strong)TTTAttributedLabel *contentLb;

@property (nonatomic,strong)OtherLoginUserInfoModel *otherLoginModel;

@property (nonatomic,strong)MKAppleLogin *appleLogin;

@end

@implementation LoginViewController

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    UIImageView* blackLineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
    blackLineImageView.hidden = YES;
    //
    [self updateTextFieldStatus];
    
    [IQKeyboardManager sharedManager].enable = NO;
  
}

- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}

- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
    return UIStatusBarAnimationNone;
}


- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.isHideNavBar = YES;
    /// 设置UI
    [self setUI];
    
    // 清空本地缓存的关注列表
    RLMRealm *realm = [RLMRealm defaultRealm];
    [realm transactionWithBlock:^{
        RLMResults<UserInfoFollowModel *> *result = [UserInfoFollowModel allObjects];
        [realm deleteObjects:result];
    }];
}

#pragma mark - 设置UI
- (void)setUI{
    
    self.view.backgroundColor = [UIColor whiteColor];
        
    [self.view addSubview:self.loginBackGroundImgView];
    [self.view addSubview:self.titleView];
    [self.view addSubview:self.phoneView];
    [self.view addSubview:self.phoneTF];
    [self.view addSubview:self.clearTextButton];
    [self.view addSubview:self.placeLb];
    [self.view addSubview:self.codeBtn];
    [self.view addSubview:self.otherView];
    [self.view addSubview:self.backButton];
    [self.view addSubview:self.contentLb];
    
    self.loginBackGroundImgView.frame = CGRectMake(0, 0, kScreenW, kScreenH);
    self.clearTextButton.hidden = YES;
  
    [self.backButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view.mas_top).offset(16 + GK_STATUSBAR_HEIGHT);
        make.left.equalTo(self.view.mas_left).offset(16);
    }];
    
    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.backButton.mas_bottom).offset(28);
        make.right.equalTo(self.view.mas_right);
        make.left.equalTo(self.view.mas_left).offset(24);
    }];
    
    
    [self.phoneView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleView.mas_bottom).offset(40);
        make.height.mas_equalTo(44);
        make.right.equalTo(self.view.mas_right).offset(-16);
        make.left.equalTo(self.view.mas_left).offset(16);
    }];
    
    [self.placeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.phoneView);
        make.left.equalTo(self.phoneView).offset(20);
    }];
    
    [self.clearTextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.phoneView);
        make.right.equalTo(self.phoneView.mas_right).offset(-20);
    }];
    
    [self.phoneTF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.phoneView).offset(20);
        make.centerY.equalTo(self.phoneView);
        make.right.equalTo(self.phoneView.mas_right).offset(-20);
    }];
    [self.codeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.phoneView.mas_bottom).offset(28);
        make.height.mas_equalTo(44);
        if (@available(iOS 11,*)) {
            make.right.equalTo(self.view.mas_safeAreaLayoutGuideRight).offset(-16);
            make.left.equalTo(self.view.mas_safeAreaLayoutGuideLeft).offset(16);
        }else{
            make.left.equalTo(self.view).offset(16);
            make.right.equalTo(self.view).offset(-16);
        }
    }];
    [self.contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.codeBtn.mas_bottom).offset(8);
        make.left.equalTo(self.view).offset(24);
    }];
    
    [self.otherView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.codeBtn.mas_bottom).offset(56);
        make.left.equalTo(self.view).offset(16);
        make.right.equalTo(self.view).offset(-16);
    }];
}

#pragma mark - UITextFieldDelegate
- (void)textDidChange:(UITextField *)textField{
    [self updateTextFieldStatus];
}

#pragma mark - 更新按钮状态
- (void)updateTextFieldStatus{
    self.placeLb.hidden = self.phoneTF.text.length > 0;
    if ([self.phoneTF.text isSpaceString]  && self.phoneTF.text.length > 0 ) {
        return;
    }
    self.codeBtn.enabled = self.phoneTF.text.length > 0;
    if(self.phoneTF.text.length > 11){
        self.phoneTF.text = [self.phoneTF.text substringToIndex:11];
        return;
    }
    if (self.phoneTF.text.length == 0) {
        self.codeBtn.selected = NO;
        self.clearTextButton.hidden = YES;
    }else{
        self.codeBtn.selected = YES;
        self.clearTextButton.hidden = NO;
    }
}

#pragma mark - 按钮点击事件
- (void)codeMethod{    
    // 判断手机号的正则
    [self.view endEditing:YES];

    if ([RPAppManager isShowNetworkView]) {
        [WHToast showMessage:@"网络好像有点问题，请检查后重试" duration:2 finishHandler:nil];
        return;
    }
    
    BOOL isPhone = NO;
    
    if ([self.phoneTF.text cl_removeSpaceString].length == 11 && [[self.phoneTF.text substringToIndex:1] isEqualToString:@"1"]) {
        isPhone = YES;
    }
    if (!isPhone) {
        [WHToast showImage:[UIImage imageNamed:@"toast_tag_error"] message:@"请输入正确的手机号" originY:0 duration:2 finishHandler:nil];
        return;
    }
    
    [self sendMethod];
    

}
#pragma mark - action
- (void)sendMethod{
    
    self.codeBtn.userInteractionEnabled = NO;
    
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"phone"] = self.phoneTF.text;
    param[@"md5"] = [RPAppManager md5StrWithApi:SendCode];
    [[RPNetworkExtensionTool sharedTool]requestPOST:kGET_REQUEST_URL(SendCode) parames:param success:^(id responseObj) {
    
        self.codeBtn.userInteractionEnabled = YES;
        
        [MGJRouter openURL:@"local://ddup/register" withUserInfo:@{@"navigationVC":self.navigationController,@"appLogin":@(self.isAppLogin),@"phone":self.phoneTF.text} completion:nil];
        
    } failure:^(NSError *error) {
        
        self.codeBtn.userInteractionEnabled = YES;
        
        NSString *msg = error.code == 10010?@"帐号异常，请联系客服":@"登录状态已失效，请重新登录";
        [WHToast showImage:[UIImage imageNamed:@"toast_tag_error"] message:msg duration:2 finishHandler:nil];
    }];
    
}

- (void)backMethod{
    if (self.isAppLogin) {
    
        DiscoverListViewController *vc = [[DiscoverListViewController alloc]init];
        NavigationViewController *nav = [[NavigationViewController alloc]initWithRootViewController:vc];
        [UIApplication sharedApplication].keyWindow.rootViewController = nav;
        //        TabBarViewController *tabVC = [[TabBarViewController alloc]init];
//        [MGJRouter openURL:@"local://ddup/rootVC" withUserInfo:nil completion:nil];
    }else{
        [self.navigationController popViewControllerAnimated:NO];
    }
}

- (void)clearTextMethod{

    self.phoneTF.text = @"";

    self.placeLb.hidden = NO;
    self.codeBtn.enabled = NO;
    self.codeBtn.selected = NO;

    self.clearTextButton.hidden = YES;
}

#pragma mark - 懒加载
- (LoginAndRegisterTitleView *)titleView{
    if (!_titleView) {
        _titleView = [[LoginAndRegisterTitleView alloc]initWithMainTitle:@"登录/注册" andSubTitle:@"未注册手机号登录即可完成注册"];
    }
    return _titleView;
}
- (UILabel *)placeLb{
    if (!_placeLb) {
        _placeLb = [[UILabel alloc]init];
        _placeLb.text = @"请输入手机号";
        _placeLb.textColor = RGBA(204, 204, 204, 1);
        _placeLb.font = font(14);
    }
    return _placeLb;
}

- (UITextField *)phoneTF{
    if (!_phoneTF) {
        _phoneTF = [[UITextField alloc]init];
        _phoneTF.keyboardType = UIKeyboardTypeNumberPad;
        [_phoneTF addTarget:self action:@selector(textDidChange:) forControlEvents:UIControlEventEditingChanged];
        _phoneTF.returnKeyType = UIReturnKeyDone;
        _phoneTF.textColor = [UIColor whiteColor];
        _phoneTF.font = font(14);
        [_phoneTF becomeFirstResponder];
    }
    return _phoneTF;
}
- (UIButton *)clearTextButton{
    if (!_clearTextButton) {
        _clearTextButton = [[UIButton alloc]init];
        [_clearTextButton setImage:[UIImage imageNamed:@"common_clear_tag"] forState:UIControlStateNormal];
        [_clearTextButton setImage:[UIImage imageNamed:@"common_clear_tag"] forState:UIControlStateHighlighted];
        [_clearTextButton addTarget:self action:@selector(clearTextMethod) forControlEvents:UIControlEventTouchUpInside];
    }
    return _clearTextButton;
}

- (UIView *)phoneView{
    if (!_phoneView) {
        _phoneView = [[UIView alloc]init];
        _phoneView.backgroundColor = RGBA(255, 255, 255, 0.2);
        _phoneView.layer.cornerRadius = 22;
        _phoneView.layer.masksToBounds = YES;
    }
    return _phoneView;
}

-(UIButton *)codeBtn{
    if (!_codeBtn) {
        _codeBtn = [[UIButton alloc]init];
        [_codeBtn setTitle:@"获取验证码" forState:UIControlStateNormal];
        [_codeBtn setBackgroundImage:[UIImage imageNamed:@"login_confirm_normal_tag"] forState:UIControlStateNormal];
        [_codeBtn setBackgroundImage:[UIImage imageNamed:@"login_confirm_selected_tag"] forState:UIControlStateSelected];
        
        [_codeBtn setTitleColor:RGBA(255, 255, 255, 0.5) forState:UIControlStateNormal];
        [_codeBtn setTitleColor:RGBA(255, 255, 255, 1) forState:UIControlStateSelected];
//        [_codeBtn setBackgroundImage:[UIImage imageNamed:@"login_bg_tag"] forState:UIControlStateNormal];
        [_codeBtn addTarget:self action:@selector(codeMethod) forControlEvents:UIControlEventTouchUpInside];
        _codeBtn.enabled = NO;
        
        
    }
    return _codeBtn;
}


- (CAGradientLayer *)loginBtnGradientLayer{
    if (!_loginBtnGradientLayer) {
        _loginBtnGradientLayer =  [CAGradientLayer layer];
        _loginBtnGradientLayer.frame = self.codeBtn.bounds;
        _loginBtnGradientLayer.endPoint = CGPointMake(0, 0);
        _loginBtnGradientLayer.startPoint  = CGPointMake(1.0, 0);
        _loginBtnGradientLayer.colors = @[(id)RGBA(247, 131, 97, 1).CGColor,(id)RGBA(245, 75, 100, 1).CGColor];
    }
    return _loginBtnGradientLayer;
}


- (UIButton *)backButton{
    if (!_backButton) {
        _backButton = [[UIButton alloc]init];
        [_backButton setImage:[UIImage imageNamed:@"common_back_white_tag"] forState:UIControlStateNormal];
        [_backButton addTarget:self action:@selector(backMethod) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backButton;
}

- (OtherLoginView *)otherView{
    if (!_otherView) {
        __weak typeof(self)weakSelf = self;
        _otherView = [[OtherLoginView alloc]initWithCompleteBlock:^(NSInteger index) {
            [weakSelf.view endEditing:YES];
            UMSocialPlatformType type = UMSocialPlatformType_UnKnown;
            // qq
            if (index == 0 || index == 1) {
                
                type = index == 0?UMSocialPlatformType_WechatSession:UMSocialPlatformType_QQ;
                
                [[UMSocialManager defaultManager] getUserInfoWithPlatform:type currentViewController:nil completion:^(id result, NSError *error) {
                    
                    [SVProgressHUD show];
                    
                    if (error == nil) {
                        weakSelf.otherLoginModel = [[OtherLoginUserInfoModel alloc]init];
                        UMSocialUserInfoResponse *resp = result;
                        weakSelf.otherLoginModel.openid = resp.openid;
                        weakSelf.otherLoginModel.iconurl = resp.iconurl;
                        weakSelf.otherLoginModel.name = resp.name;
                        weakSelf.otherLoginModel.gender = resp.gender;
                        [weakSelf otherLoginWithUUid:resp.openid platformType:index==0?@1:@2];
                    }else{
                        [SVProgressHUD dismiss];
                    }
                }];
            }
            // 苹果
            if (index == 2) {
                weakSelf.appleLogin = [[MKAppleLogin alloc]init];
                weakSelf.appleLogin.delegate = weakSelf;
                [weakSelf.appleLogin authorizationAppleIDButtonPressWithSuperView:weakSelf.view];
            }
        }];
    }
    return _otherView;
}

- (UIImageView *)loginBackGroundImgView{
    if (!_loginBackGroundImgView) {
        _loginBackGroundImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"login_backgroud_tag"]];
    }
    return _loginBackGroundImgView;
}

- (TTTAttributedLabel *)contentLb{
    if (!_contentLb) {
        _contentLb = [[TTTAttributedLabel alloc]initWithFrame:CGRectZero];
        _contentLb.numberOfLines = 0;
        _contentLb.delegate = self;
        _contentLb.font = [UIFont systemFontOfSize:12];
        _contentLb.textColor = [UIColor whiteColor];
        _contentLb.linkAttributes = @{(NSString *)kCTForegroundColorAttributeName:RGBA(245, 75, 100, 1),
                                      (NSString *)kCTUnderlineStyleAttributeName:[NSNumber numberWithBool:NO]};
        _contentLb.text = @"登录即表明同意《服务协议》和《用户隐私政策》";
        NSRange selRange1 = [_contentLb.text rangeOfString:@"《服务协议》"];
        NSRange selRange2 = [_contentLb.text rangeOfString:@"《用户隐私政策》"];
        [_contentLb addLinkToTransitInformation:@{@"data":[NSString stringWithFormat:@"%@user/agreement?type=serviceAgreement&navbar=no",HtmlUrl],@"type":@1} withRange:selRange1];
        [_contentLb addLinkToTransitInformation:@{@"data":[NSString stringWithFormat:@"%@user/agreement?type=userPrivacy&navbar=no",HtmlUrl],@"type":@2} withRange:selRange2];
    }
    return _contentLb;
}

- (LoginParamModel *)loginParamModel{
    if (!_loginParamModel) {
        _loginParamModel = [[LoginParamModel alloc]init];
    }
    return _loginParamModel;
}

#pragma mark - otherLogin
- (void)otherLoginWithUUid:(NSString *)uuid platformType:(NSNumber *)type{
    
    
    self.otherLoginModel.type = type;
    
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"md5"] = [RPAppManager md5StrWithApi:ThirdLogin];
    param[@"openId"] = uuid;
    param[@"type"] = type;
    [[RPNetworkExtensionTool sharedTool]requestPOST:kGET_REQUEST_URL(ThirdLogin) parames:param success:^(id responseObj) {
        BOOL isNewAccount = [responseObj[RESPONSE][@"isNew"]boolValue];
        if (isNewAccount) {
            [MGJRouter openURL:@"local://ddup/bindPhone" withUserInfo:@{@"navigationVC":self.navigationController,@"appLogin":@(self.isAppLogin),@"otherLogin":self.otherLoginModel} completion:nil];
        }else{
            [self getUserInfoById:responseObj[RESPONSE][@"id"]];
            
        }
    } failure:^(NSError *error) {        
        [WHToast showImage:[UIImage imageNamed:@"toast_tag_error"] message:error.userInfo[@"info"] duration:2 finishHandler:nil];
    }];
}


#pragma mark - MKAppleLoginDelegate
-(void)authorizationdidSuccessWithUserID:(NSString *)userID andAuthorizationCode:(NSData *)Acode andIdentityToken:(NSData *)token andEmail:(NSString *)email{
    [SVProgressHUD show];
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"identityToken"] = [[NSString alloc]initWithData:token encoding:NSUTF8StringEncoding];
    param[@"md5"] = [RPAppManager md5StrWithApi:AppleLogin];
    [[RPNetworkExtensionTool sharedTool]requestPOST:kGET_REQUEST_URL(AppleLogin) parames:param success:^(id responseObj) {
        BOOL isNewAccount = [responseObj[RESPONSE][@"isNew"]boolValue];
        if (isNewAccount) {

            OtherLoginUserInfoModel *otherInfo = [[OtherLoginUserInfoModel alloc]init];
            otherInfo.openid = responseObj[RESPONSE][@"openId"];
            otherInfo.type = @4;
            
            [MGJRouter openURL:@"local://ddup/bindPhone" withUserInfo:@{@"navigationVC":self.navigationController,@"appLogin":@(self.isAppLogin),@"otherLogin":otherInfo} completion:nil];
            
        }else{
            [self getUserInfoById:responseObj[RESPONSE][@"id"]];
        }
    } failure:^(NSError *error) {
        [WHToast showImage:[UIImage imageNamed:@"toast_tag_error"] message:error.userInfo[@"info"] duration:2 finishHandler:nil];
    }];
}
-(void)authorizationdidSuccessWithErrorCode:(NSString *)errorCode{
    NSLog(@"%@",errorCode);
}

- (void)getUserFollowListSource{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"userId"] = [RPAppManager getCustomerId];
    param[@"md5"] = [RPAppManager md5StrWithApi:GetFollowList];
    [[RPNetworkExtensionTool sharedTool]requestPOST:kGET_REQUEST_URL(GetFollowList) parames:param success:^(id responseObj) {

        NSArray *resultArray = [UserInfoFollowModel mj_objectArrayWithKeyValuesArray:responseObj[RESPONSE]];
        
        // 获取数据库单例对象
        RLMRealm *realm = [RLMRealm defaultRealm];
        // 更新当前登录这样用户的信息
        [realm transactionWithBlock:^{
            [realm addOrUpdateObjects:resultArray];
        }];
        
        __weak typeof(self)weakSelf = self;
        [WHToast showImage:[UIImage imageNamed:@"toast_tag_success"] message:@"登录成功" originY:0 duration:1 finishHandler:^{
            if (weakSelf.isAppLogin) {
                DiscoverListViewController *vc = [[DiscoverListViewController alloc]init];
                NavigationViewController *nav = [[NavigationViewController alloc]initWithRootViewController:vc];
                [UIApplication sharedApplication].keyWindow.rootViewController = nav;
            }else{
                __block NSInteger index = -1;
                [weakSelf.navigationController.viewControllers enumerateObjectsUsingBlock:^(__kindof UIViewController * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                    if ([obj isKindOfClass:[self class]]) {
                        index = idx;
                        *stop = YES;
                    }
                }];
                
                if (index != -1) {
                    [weakSelf.navigationController popToViewController:weakSelf.navigationController.viewControllers[index - 1] animated:NO];
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"updateUserInfoSource" object:nil];
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"updateUserInfoUseage" object:nil];
                    // 发送通知 刷新页面按钮状态
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"updateLoginUserInfoFollowListStatus" object:nil];
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"updateRefreshToken" object:nil];
                    
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"updateTabItemIndex" object:nil];
                    
                }
            }
            [MobClick event:@"login_phone"];
        }];

    } failure:^(NSError *error) {
        [WHToast showImage:[UIImage imageNamed:@"toast_tag_error"] message:error.userInfo[@"info"] duration:2 finishHandler:nil];
    }];
}



- (void)getUserInfoById:(NSNumber *)userId{
    // 请求用户登录信息
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    param[@"id"] = userId;
    param[@"md5"] = [RPAppManager md5StrWithApi:GetUser];
    [[RPNetworkExtensionTool sharedTool]requestPOST:kGET_REQUEST_URL(GetUser) parames:param success:^(id responseObj) {
        
        UserInfoModel *userInfo = [UserInfoModel mj_objectWithKeyValues:responseObj[RESPONSE]];
        [userInfo save];
        
        [self getUserFollowListSource];
        
        if (self.otherLoginModel.type.intValue == 1) {
            [MobClick event:@"login_other_wechat"];
            [MobClick profileSignInWithPUID:userInfo.id.stringValue provider:@"WX"];
        }else if (self.otherLoginModel.type.intValue == 2) {
            [MobClick event:@"login_other_qq"];
            [MobClick profileSignInWithPUID:userInfo.id.stringValue provider:@"QQ"];
        }else{
            [MobClick event:@"login_other_apple"];
            [MobClick profileSignInWithPUID:userInfo.id.stringValue provider:@"APPLE"];
        }
    } failure:^(NSError *error) {
        [WHToast showImage:[UIImage imageNamed:@"toast_tag_error"] message:error.userInfo[@"info"] duration:2 finishHandler:nil];
    }];
}

#pragma mark - other
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
   [self.view endEditing:YES];
}

- (UIImageView *)findHairlineImageViewUnder:(UIView *)view
{
    if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0)
    {
        return (UIImageView *)view;
    }
    for (UIView *subview in view.subviews) {
        UIImageView *imageView = [self findHairlineImageViewUnder:subview];
        if (imageView) {
            return imageView;
        }
    }
    return nil;
}

- (void)attributedLabel:(TTTAttributedLabel *)label didSelectLinkWithTransitInformation:(NSDictionary *)components {
    RPWebViewController *webVC = [[RPWebViewController alloc]init];
    webVC.webUrl = components[@"data"];
    if ([components[@"type"] intValue] == 1) {
        webVC.title = @"用户协议";
    }else{
        webVC.title = @"隐私政策";
    }
    [self.navigationController pushViewController:webVC animated:YES];
}
- (void)dealloc{
    
}
@end
